package com.neusoft.nepg.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.neusoft.common.domain.GriderTest;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;

import java.util.List;

public interface GriderTestMapper extends BaseMapper<GriderTest> {
    @Select("select count(*) from grider_test")
    int countMesg();
    @Select("select count(*) from grider_test where level = 2")
    int countWell();
    @Select("SELECT COUNT(DISTINCT sm.city) FROM grider_test gt JOIN supervisor_mesg sm ON gt.Smesg_id = sm.id WHERE sm.city IN (1,2,3,4,5,16,27,50,64,73,86,99,110,127,136,147,164,182,199,213,234,248,269,278,296,312,320,330,344,351,356,378,390,391)")
    int countCapital();

    @Select("SELECT COUNT(DISTINCT sm.city) FROM grider_test gt JOIN supervisor_mesg sm ON gt.Smesg_id = sm.id WHERE sm.city IN (1,3,213,214,4,2,248,182,229,320,99,218,86,50,148,147,199,73,164,296,51,330,5,128,16,90,269,110,356,100,87,127,64,136,89)")
    int countBigCity();
    @Select("select * from grider_test where Smesg_id = #{id}")
    @Results({
            @Result(column = "PM2_5",property = "PM")
    })
    List<GriderTest> findTest(int id);
    @Insert("insert into grider_test (SO2, CO, PM2_5, Smesg_id, level, date, time) values (#{sO2}, #{cO}, #{pM}, #{smesg_id}, #{level}, #{date}, #{time})")
    Boolean save(GriderTest msg);

}
